package com.ev.apis.controller.aslreport;

import cn.afterturn.easypoi.entity.vo.TemplateExcelConstants;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import cn.afterturn.easypoi.view.PoiBaseView;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.resource.ClassPathResource;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ev.asl.constant.AslConstant;
import com.ev.asl.dao.AslBarCodeDao;
import com.ev.asl.service.KisBasicsService;
import com.ev.asl.vo.voBillOfPull.KisReceiveStockVo;
import com.ev.aslReport.service.ReportService;

import com.ev.aslReport.vo.ReportTwoVo;
import com.ev.custom.domain.DictionaryDO;
import com.ev.custom.service.DictionaryService;
import com.ev.framework.annotation.EvApiByToken;

import com.ev.framework.utils.DateUtils;
import com.ev.framework.utils.R;

import com.google.common.collect.Maps;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.Triple;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author: π
 * @date 2022/7/10
 * @described:
 */
@Api(value = "/", tags = "仓库管理报表分析API")
@RestController
@Slf4j
public class AslReportOfNewController {
    //    @Resource
//    private WarehouseAccountingReportService reportService;
//    @Resource
//    private K3MaterialStoragePresentStateService service;
//    @Resource
//    private K3MaterialOutboundDetailService k3MaterialOutboundDetailService;
//    @Resource
//    private K3SafetyInTheWarehouseStatusService k3SafetyInTheWarehouseStatusService;
//    @Resource
//    private K3ExpectedStatusInTheLibraryService k3ExpectedStatusInTheLibraryService;
//    @Resource
//    private K3FinalGoodsInStockSiteAsIsService k3FinalGoodsInStockSiteAsIsService;
//    @Resource
//    private K3CtWpDatabaseService k3CtWpDatabaseService;
//    @Resource
//    private K3SalesStoreHouseService k3SalesStoreHouseService;
    @Autowired
    private DictionaryService dictionaryService;

    @Resource
    private ReportService reportService;

    @Resource
    private KisBasicsService kisBasicsService;

    @Resource
    private AslBarCodeDao aslBarCodeDao;

    @EvApiByToken(value = "/apis/asl/report/warehouse/getFactorys", method = RequestMethod.GET, apiTitle = "获取仓库列表")
    @ApiOperation("获取仓库列表")
    public R getFactorys(@ApiParam() @RequestParam(value = "status", required = false,defaultValue = "0") String status) {
        Map<String, Object> results = new HashMap<>();
        HashMap<String, Object> dicMap = new HashMap<>();
        dicMap.put("typeId", 110);
        List<DictionaryDO> dicList = dictionaryService.list(dicMap);
        List<String> collect = dicList.stream().map(DictionaryDO::getValue).collect(Collectors.toList());
        if (AslConstant.ONE.toString().equals(status)) {
            collect = collect.stream().filter(e -> !("附属品库B".equals(e) || "车间仓库".equals(e) || "报废仓库".equals(e))
            ).collect(Collectors.toList());
        }
        results.put("data", collect);
        return R.ok(results);

    }

    @EvApiByToken(value = "/apis/asl/report/warehouse/getFactorys2", method = RequestMethod.GET, apiTitle = "获取仓库列表")
    @ApiOperation("获取仓库列表(只显示自制品容器成品库)")
    public R getFactorys2() {
        Map<String, Object> results = new HashMap<>();
        HashMap<String, Object> dicMap = new HashMap<>();
        dicMap.put("typeId", 110);
        List<DictionaryDO> dicList = dictionaryService.list(dicMap);
        List<String> collect = dicList.stream().filter(dictionaryDO -> "自制品容器成品库".equals(dictionaryDO.getValue())).map(DictionaryDO::getValue).collect(Collectors.toList());
        results.put("data", collect);
        return R.ok(results);

    }

    @EvApiByToken(value = "/apis/asl/report/warehouse/inOutStockItem", method = RequestMethod.POST, apiTitle = "1——物料收发明细")
    @ApiOperation("1——物料收发明细")
    public R inOutStockItem(
            @ApiParam(value = "开始时间", required = true) @RequestParam(value = "startTime", defaultValue = "") String startTime,
            @ApiParam(value = "结束时间", required = true) @RequestParam(value = "endTime", defaultValue = "") String endTime,
            @ApiParam(value = "物料名称") @RequestParam(value = "materielName", defaultValue = "", required = false) String materielName,
            @ApiParam(value = "物料代码") @RequestParam(value = "materialNumber", defaultValue = "", required = false) String materialNumber,
//            @ApiParam(value = "物料ID", required = true) @RequestParam(value = "materielId", defaultValue = "") Long materielId,
            @ApiParam(value = "规格型号") @RequestParam(value = "materialModel", defaultValue = "", required = false) String materialModel,
            @ApiParam(value = "仓库") @RequestParam(value = "stockName", defaultValue = "", required = false) String stockName,
            @ApiParam(value = "当前第几页", required = true) @RequestParam(value = "pageno", defaultValue = "1") Integer pageNo,
            @ApiParam(value = "一页多少条", required = true) @RequestParam(value = "pagesize", defaultValue = "20") Integer pageSize
    ) {
        if (!ObjectUtils.isEmpty(stockName)) {
            R remoteDataOfBefore = reportService.getRemoteDataOfBefore(1, materielName, materialNumber, startTime, endTime, stockName, pageSize, pageNo, null, materialModel);
            return remoteDataOfBefore;
        }
        R resultTemp = new R();
        List<Object> dataTemp = new ArrayList<>();
        Integer pageSizeTemp = 0;
        Integer pageNoTemp = 0;
        Integer totalTemp = 0;
        Integer totalStorageTemp = 0;
        BigDecimal totalOutCount = BigDecimal.ZERO;
        BigDecimal totalInCount = BigDecimal.ZERO;
        BigDecimal totalBalanceCount = BigDecimal.ZERO;
        //不要问为什么写的这么丑陋...问就是不知道
        //1、先查出爱赛露目前的仓库
        HashMap<String, Object> dicMap = new HashMap<>();
        dicMap.put("typeId", 110);
        List<DictionaryDO> dicList = dictionaryService.list(dicMap);
        List<String> factoryNames = dicList.stream().map(DictionaryDO::getValue).collect(Collectors.toList());
        //2、遍历仓库查询数据
        for (int i = 0; i < factoryNames.size(); i++) {
            resultTemp = reportService.getRemoteDataOfBefore(1, materielName, materialNumber, startTime, endTime, factoryNames.get(i), pageSize, pageNo, null, materialModel);
            if (ObjectUtil.isEmpty(resultTemp) || ObjectUtil.isEmpty(resultTemp.get("data"))) continue;
            pageSizeTemp = pageSizeTemp + new Integer(resultTemp.containsKey("pageSize") ? resultTemp.get("pageSize").toString() : "0");
            pageNoTemp = pageSizeTemp + new Integer(resultTemp.containsKey("pageNo") ? resultTemp.get("pageNo").toString() : "0");
            totalTemp = pageSizeTemp + new Integer(resultTemp.containsKey("total") ? resultTemp.get("total").toString() : "0");
            totalStorageTemp = pageSizeTemp + new Integer(resultTemp.containsKey("totalStorageQty") ? resultTemp.get("totalStorageQty").toString() : "0");
            dataTemp.addAll(resultTemp.containsKey("data") ? JSON.parseArray(resultTemp.get("data").toString()) : new ArrayList<>());
            totalOutCount = totalOutCount.add(new BigDecimal(resultTemp.containsKey("totalOutCount") ? resultTemp.get("totalOutCount").toString() : "0"));
            totalInCount = totalInCount.add(new BigDecimal(resultTemp.containsKey("totalInCount") ? resultTemp.get("totalInCount").toString() : "0"));
            totalBalanceCount = totalBalanceCount.add(new BigDecimal(resultTemp.containsKey("totalBalanceCount") ? resultTemp.get("totalBalanceCount").toString() : "0"));
        }
        Map<String, Object> dataMap = Maps.newHashMapWithExpectedSize(2);
        dataMap.put("data", dataTemp);
        dataMap.put("pageNo", pageNoTemp);
        dataMap.put("pageSize", pageSizeTemp);
        dataMap.put("total", totalTemp);
        dataMap.put("totalPage", 1);//前端现在传的pageSize是10000，所以没有影响
        dataMap.put("totalStorageQty", totalStorageTemp);
        dataMap.put("totalOutCount", totalOutCount);
        dataMap.put("totalInCount", totalInCount);
        dataMap.put("totalBalanceCount", totalBalanceCount);
        return R.ok(dataMap);
    }

    @EvApiByToken(value = "/apis/exportExcel/inOutStockItem", method = RequestMethod.GET, apiTitle = "成型生产指示分页列表(导出)")
    @ApiOperation("物料收发明细(导出)")
    public void exportInOutStockItem(
            @ApiParam(value = "开始时间", required = true) @RequestParam(value = "startTime", defaultValue = "") String startTime,
            @ApiParam(value = "结束时间", required = true) @RequestParam(value = "endTime", defaultValue = "") String endTime,
            @ApiParam(value = "物料名称") @RequestParam(value = "materielName", defaultValue = "", required = false) String materielName,
            @ApiParam(value = "物料代码") @RequestParam(value = "materialNumber", defaultValue = "", required = false) String materialNumber,
            @ApiParam(value = "规格型号") @RequestParam(value = "materialModel", defaultValue = "", required = false) String materialModel,
            @ApiParam(value = "仓库") @RequestParam(value = "stockName", defaultValue = "", required = false) String stockName,
            HttpServletRequest request, HttpServletResponse response,
            ModelMap modelMap) {
        List<Object> dataTemp = new ArrayList<>();
        Map<String, Object> map = Maps.newHashMap();
        Integer pageNo = new Integer(1);
        Integer pageSize = new Integer(20);
        if (!ObjectUtils.isEmpty(stockName)) {
            R remoteDataOfBefore = reportService.getRemoteDataOfBefore(1, materielName, materialNumber, startTime, endTime, stockName, pageSize, pageNo, null, materialModel);
            if (!ObjectUtils.isEmpty(remoteDataOfBefore) && ObjectUtil.isNotEmpty(remoteDataOfBefore.get("total"))) {
                pageSize = new Integer(remoteDataOfBefore.get("total").toString());
                pageNo = 1;
                R remoteDataOfBefore2 = reportService.getRemoteDataOfBefore(1, materielName, materialNumber, startTime, endTime, stockName, pageSize, pageNo, null, materialModel);
                log.debug("===============================remoteDataOfBefore2:{}", remoteDataOfBefore2);
                if (!ObjectUtils.isEmpty(remoteDataOfBefore2) && ObjectUtil.isNotEmpty(remoteDataOfBefore2.get("total"))) {
                    JSONArray data = (JSONArray) remoteDataOfBefore2.get("data");
                    map.put("list", data);
                    dataTemp.addAll(remoteDataOfBefore2.containsKey("data") ? JSON.parseArray(remoteDataOfBefore2.get("data").toString()) : new ArrayList<>());
                    log.debug("===============================data:{}", data);
                }
            }
        } else {
            HashMap<String, Object> dicMap = new HashMap<>();
            dicMap.put("typeId", 110);
            List<DictionaryDO> dicList = dictionaryService.list(dicMap);
            List<String> factoryNames = dicList.stream().map(DictionaryDO::getValue).collect(Collectors.toList());
            for (int i = 0; i < factoryNames.size(); i++) {
                R remoteDataOfBefore = reportService.getRemoteDataOfBefore(1, materielName, materialNumber, startTime, endTime, factoryNames.get(i), pageSize, pageNo, null, materialModel);
                if (!ObjectUtils.isEmpty(remoteDataOfBefore) && ObjectUtil.isNotEmpty(remoteDataOfBefore.get("total"))) {
                    pageSize = new Integer(remoteDataOfBefore.get("total").toString());
                    pageNo = 1;
                    R remoteDataOfBefore2 = reportService.getRemoteDataOfBefore(1, materielName, materialNumber, startTime, endTime, factoryNames.get(i), pageSize, pageNo, null, materialModel);
                    log.debug("===============================remoteDataOfBefore2:{}", remoteDataOfBefore2);
                    if (!ObjectUtils.isEmpty(remoteDataOfBefore2) && ObjectUtil.isNotEmpty(remoteDataOfBefore2.get("total"))) {
                        JSONArray data = (JSONArray) remoteDataOfBefore2.get("data");
                        dataTemp.addAll(remoteDataOfBefore2.containsKey("data") ? JSON.parseArray(remoteDataOfBefore2.get("data").toString()) : new ArrayList<>());
                        log.debug("===============================data:{}", data);
                    }
                }
            }
            map.put("list", dataTemp);
        }
        ClassPathResource classPathResource = new ClassPathResource(
                "poi/inOutStockItem.xlsx");
        TemplateExportParams result = new TemplateExportParams(classPathResource.getPath());
        modelMap.put(TemplateExcelConstants.FILE_NAME, "物料收发明细");
        modelMap.put(TemplateExcelConstants.PARAMS, result);
        modelMap.put(TemplateExcelConstants.MAP_DATA, map);
        PoiBaseView.render(modelMap, request, response,
                TemplateExcelConstants.EASYPOI_TEMPLATE_EXCEL_VIEW);
    }

    @EvApiByToken(value = "/apis/asl/report/MaterialStoragePresentState/query", method = RequestMethod.POST, apiTitle = "2——物料入库明细")
    @ApiOperation("2——物料入库明细")
    public R queryMaterialReceiveDispatchDetail(
            @ApiParam(value = "当前第几页", required = true) @RequestParam(value = "pageno", defaultValue = "1") Integer pageNo,
            @ApiParam(value = "一页多少条", required = true) @RequestParam(value = "pagesize", defaultValue = "20") Integer pageSize,
            @ApiParam(value = "物料代码") @RequestParam(value = "materialNumber", defaultValue = "", required = false) String materialNumber,
            @ApiParam(value = "物料名称") @RequestParam(value = "materielName", defaultValue = "", required = false) String materielName,
            @ApiParam(value = "规格型号") @RequestParam(value = "materialModel", defaultValue = "", required = false) String materialModel,
            @ApiParam(value = "仓库") @RequestParam(value = "stockName", defaultValue = "", required = false) String stockName,
            @ApiParam(value = "起始时间") @RequestParam(value = "dateStart", defaultValue = "", required = false) String dateStart,
            @ApiParam(value = "结束时间") @RequestParam(value = "dateEnd", defaultValue = "", required = false) String dateEnd
    ) {
        //        return service.materialStoragePresentStateSync(param);
        return reportService.getRemoteDataOfBefore(2, materielName, materialNumber, dateStart, dateEnd, stockName, pageSize, pageNo, null, materialModel);
    }

    @EvApiByToken(value = "/apis/asl/report/MaterialStoragePresentState/query2", method = RequestMethod.POST, apiTitle = "2——物料入库明细")
    @ApiOperation("成品位置在库现况表")
    public R queryMaterialReceiveDispatchDetail1(
            @ApiParam(value = "当前第几页", required = true) @RequestParam(value = "pageno", defaultValue = "1") Integer pageNo,
            @ApiParam(value = "一页多少条", required = true) @RequestParam(value = "pagesize", defaultValue = "20") Integer pageSize,
            @ApiParam(value = "物料名称") @RequestParam(value = "materielName", defaultValue = "", required = false) String materielName,
            @ApiParam(value = "物料代码") @RequestParam(value = "materialNumber", defaultValue = "", required = false) String materialNumber,
            @ApiParam(value = "规格型号") @RequestParam(value = "materialModel", defaultValue = "", required = false) String materialModel,
            @ApiParam(value = "仓库") @RequestParam(value = "stockName", defaultValue = "", required = false) String stockName,
            @ApiParam(value = "起始时间") @RequestParam(value = "dateStart", defaultValue = "", required = false) String dateStart,
            @ApiParam(value = "结束时间") @RequestParam(value = "dateEnd", defaultValue = "", required = false) String dateEnd
    ) {
        String filter = "";
        if (ObjectUtil.isNotEmpty(materialNumber)) filter = filter + " and 物料代码='" + materialNumber + "'";
        if (ObjectUtil.isNotEmpty(stockName)) filter = filter + " and 仓库名称='" + stockName + "'";
        if (ObjectUtil.isNotEmpty(stockName))
            filter = filter + " and 物料名称 like '" + ("%" + materielName + "%") + "'";
        if (ObjectUtil.isNotEmpty(stockName))
            filter = filter + " and 规格型号 like '" + ("%" + materialModel + "%") + "'";
        Triple<Boolean, String, List<KisReceiveStockVo>> stockList = kisBasicsService.realTimeStockBalanceEnquiry222(filter);
        List<KisReceiveStockVo> right = stockList.getRight();
        List<ReportTwoVo> collect = new ArrayList<>();
        List<ReportTwoVo> result = new ArrayList<>();
        Map<String, Map<String, Object>> stockInListMap = new HashMap<>();
        if (ObjectUtil.isNotEmpty(right)) {
            List<String> batchNos = right.stream().map(KisReceiveStockVo::getFBatchNo).flatMap(batch -> Arrays.stream(batch.split(","))).distinct().collect(Collectors.toList());
            HashMap<String, Object> stockDOSMap = new HashMap<>();
            stockDOSMap.put("batchs", batchNos);
            List<Map<String, Object>> stockInList = aslBarCodeDao.getStockInList(stockDOSMap);
            stockInListMap = stockInList
                    .stream().collect(Collectors.toMap(item -> item.get("batchNo").toString(), item -> item, (v1, v2) -> v1));
        }
        Map<String, Object> map = new HashMap<>();
        BigDecimal totalStockQty = new BigDecimal(AslConstant.ZERO);
        if (right.size() > 0) {
            for (KisReceiveStockVo item : right) {
                try {
                    ReportTwoVo vo = new ReportTwoVo();
                    Map<String, Object> stockDO = new HashMap<>();
                    ArrayList<String> batchs = ObjectUtil.isNotEmpty(item.getFBatchNo()) ? new ArrayList(Arrays.asList(item.getFBatchNo().split(","))) : new ArrayList<String>();
                    if (ObjectUtil.isNotEmpty(batchs) && stockInListMap.containsKey(batchs.get(0))) {
                        stockDO = stockInListMap.get(batchs.get(0));
                    }
                    vo.setOperatorName(ObjectUtil.isNotEmpty(stockDO.get("operatorName")) ? stockDO.get("operatorName").toString() : "");
                    vo.setInTime(ObjectUtil.isNotEmpty(stockDO.get("createTime")) ? stockDO.get("createTime").toString() : "");
                    vo.setBatchNo(item.getFBatchNo());
                    vo.setMaterialNumber(item.getMaterialCode());
                    vo.setMaterialName(item.getFItemName());
                    vo.setMaterialModel(item.getFModel());
                    vo.setUnitName(item.getUnitName());
                    vo.setStock(item.getFStockId_FName());
                    vo.setMaterieCode(item.getMaterialCode());
                    vo.setStockQty(new BigDecimal(Double.valueOf(item.getFQty())));
                    vo.setFreightSpace(item.getFStockPlaceID_FName());
                    vo.setFrecords(Integer.valueOf(item.getFRECORDS()));
                    totalStockQty = totalStockQty.add(vo.getStockQty());
                    result.add(vo);
                } catch (Exception e) {
                    log.info("----2  数据解析出现异常：");
                }
            }
        }
        if (!CollectionUtils.isEmpty(result)) {
            collect = result.stream().sorted(Comparator.comparing(e -> e.getFrecords())).collect(Collectors.toList());
        }
        map.put("data", JSONArray.parseArray(JSON.toJSONString(collect)));
        map.put("totalStockQty", totalStockQty);
        return R.ok(map);
    }

    @EvApiByToken(value = "/apis/exportExcel/materialStoragePresentState", method = RequestMethod.GET, apiTitle = "成型生产指示分页列表(导出)")
    @ApiOperation("物料入库明细(导出)")
    public void exportMaterialStoragePresentState(
            @ApiParam(value = "物料代码") @RequestParam(value = "materialNumber", defaultValue = "", required = false) String materialNumber,
            @ApiParam(value = "仓库") @RequestParam(value = "stockName", defaultValue = "", required = false) String stockName,
            @ApiParam(value = "物料名称") @RequestParam(value = "materielName", defaultValue = "", required = false) String materielName,
            @ApiParam(value = "规格型号") @RequestParam(value = "materialModel", defaultValue = "", required = false) String materialModel,
            @ApiParam(value = "起始时间") @RequestParam(value = "dateStart", defaultValue = "", required = false) String dateStart,
            @ApiParam(value = "结束时间") @RequestParam(value = "dateEnd", defaultValue = "", required = false) String dateEnd,
            HttpServletRequest request, HttpServletResponse response,
            ModelMap modelMap) {
        Map<String, Object> map = Maps.newHashMap();
        Integer pageNo = new Integer(1);
        Integer pageSize = new Integer(20);
        R remoteDataOfBefore = reportService.getRemoteDataOfBefore(2, materielName, materialNumber, dateStart, dateEnd, stockName, pageSize, pageNo, null, materialModel);
        if (!ObjectUtils.isEmpty(remoteDataOfBefore) && ObjectUtil.isNotEmpty(remoteDataOfBefore.get("total"))) {
            pageSize = new Integer(remoteDataOfBefore.get("total").toString());
            pageNo = 1;
            R remoteDataOfBefore2 = reportService.getRemoteDataOfBefore(2, materielName, materialNumber, dateStart, dateEnd, stockName, pageSize, pageNo, null, materialModel);
            log.debug("===============================remoteDataOfBefore2:{}", remoteDataOfBefore2);
            if (!ObjectUtils.isEmpty(remoteDataOfBefore2) && ObjectUtil.isNotEmpty(remoteDataOfBefore2.get("total"))) {
                JSONArray data = (JSONArray) remoteDataOfBefore2.get("data");
                map.put("list", data);
                log.debug("===============================data:{}", data);
            }
        }
        ClassPathResource classPathResource = new ClassPathResource(
                "poi/MaterialStoragePresentState2.xlsx");
        TemplateExportParams result = new TemplateExportParams(classPathResource.getPath());
        modelMap.put(TemplateExcelConstants.FILE_NAME, "物料入库明细");
        modelMap.put(TemplateExcelConstants.PARAMS, result);
        modelMap.put(TemplateExcelConstants.MAP_DATA, map);
        PoiBaseView.render(modelMap, request, response,
                TemplateExcelConstants.EASYPOI_TEMPLATE_EXCEL_VIEW);
    }

    @EvApiByToken(value = "/apis/asl/report/materialOutboundDetail/query", method = RequestMethod.POST, apiTitle = "3——物料出库明细")
    @ApiOperation("3——物料出库明细")
    public R queryMaterialOutboundDetail(
            @ApiParam(value = "当前第几页", required = true) @RequestParam(value = "pageno", defaultValue = "1") Integer pageNo,
            @ApiParam(value = "一页多少条", required = true) @RequestParam(value = "pagesize", defaultValue = "20") Integer pageSize,
            @ApiParam(value = "物料代码") @RequestParam(value = "materialNumber", defaultValue = "", required = false) String materialNumber,
            @ApiParam(value = "物料名称") @RequestParam(value = "materielName", defaultValue = "", required = false) String materielName,
            @ApiParam(value = "规格型号") @RequestParam(value = "materialModel", defaultValue = "", required = false) String materialModel,
            @ApiParam(value = "仓库") @RequestParam(value = "stockName", defaultValue = "", required = false) String stockName,
            @ApiParam(value = "起始时间") @RequestParam(value = "dateStart", defaultValue = "", required = false) String dateStart,
            @ApiParam(value = "结束时间") @RequestParam(value = "dateEnd", defaultValue = "", required = false) String dateEnd
    ) {
//        return k3MaterialOutboundDetailService.materialOutboundDetailSync(param);
        return reportService.getRemoteDataOfBefore(3, materielName, materialNumber, dateStart, dateEnd, stockName, pageSize, pageNo, null, materialModel);
    }

    @EvApiByToken(value = "/apis/exportExcel/query", method = RequestMethod.GET, apiTitle = "成型生产指示分页列表(导出)")
    @ApiOperation("物料出库明细(导出)")
    public void exportQuery(
            @ApiParam(value = "物料代码") @RequestParam(value = "materialNumber", defaultValue = "", required = false) String materialNumber,
            @ApiParam(value = "物料名称") @RequestParam(value = "materielName", defaultValue = "", required = false) String materielName,
            @ApiParam(value = "仓库") @RequestParam(value = "stockName", defaultValue = "", required = false) String stockName,
            @ApiParam(value = "规格型号") @RequestParam(value = "materialModel", defaultValue = "", required = false) String materialModel,
            @ApiParam(value = "起始时间") @RequestParam(value = "dateStart", defaultValue = "", required = false) String dateStart,
            @ApiParam(value = "结束时间") @RequestParam(value = "dateEnd", defaultValue = "", required = false) String dateEnd,
            HttpServletRequest request, HttpServletResponse response,
            ModelMap modelMap) {
        Map<String, Object> map = Maps.newHashMap();
        Integer pageNo = new Integer(1);
        Integer pageSize = new Integer(20);
        R remoteDataOfBefore = reportService.getRemoteDataOfBefore(3, materielName, materialNumber, dateStart, dateEnd, stockName, pageSize, pageNo, null, materialModel);
        if (!ObjectUtils.isEmpty(remoteDataOfBefore) && ObjectUtil.isNotEmpty(remoteDataOfBefore.get("total"))) {
            pageSize = new Integer(remoteDataOfBefore.get("total").toString());
            pageNo = 1;
            R remoteDataOfBefore2 = reportService.getRemoteDataOfBefore(3, materielName, materialNumber, dateStart, dateEnd, stockName, pageSize, pageNo, null, materialModel);
            log.debug("===============================remoteDataOfBefore2:{}", remoteDataOfBefore2);
            if (!ObjectUtils.isEmpty(remoteDataOfBefore2) && ObjectUtil.isNotEmpty(remoteDataOfBefore2.get("total"))) {
                JSONArray data = (JSONArray) remoteDataOfBefore2.get("data");
                map.put("list", data);
                log.debug("===============================data:{}", data);
            }
        }
        ClassPathResource classPathResource = new ClassPathResource(
                "poi/query.xlsx");
        TemplateExportParams result = new TemplateExportParams(classPathResource.getPath());
        modelMap.put(TemplateExcelConstants.FILE_NAME, "物料出库明细");
        modelMap.put(TemplateExcelConstants.PARAMS, result);
        modelMap.put(TemplateExcelConstants.MAP_DATA, map);
        PoiBaseView.render(modelMap, request, response,
                TemplateExcelConstants.EASYPOI_TEMPLATE_EXCEL_VIEW);
    }

    @EvApiByToken(value = "/apis/asl/report/SafetyInTheWarehouseStatus/query", method = RequestMethod.POST, apiTitle = "4——安全在库现况")
    @ApiOperation("4——安全在库现况")
    public R queryMaterialReceiveDispatchDetail2(
            @ApiParam(value = "当前第几页", required = true) @RequestParam(value = "pageno", defaultValue = "1") Integer pageNo,
            @ApiParam(value = "一页多少条", required = true) @RequestParam(value = "pagesize", defaultValue = "20") Integer pageSize,
            @ApiParam(value = "起始时间") @RequestParam(value = "dateStart", defaultValue = "", required = false) String dateStart,
            @ApiParam(value = "物料名称") @RequestParam(value = "materielName", defaultValue = "", required = false) String materielName,
            @ApiParam(value = "规格型号") @RequestParam(value = "materialModel", defaultValue = "", required = false) String materialModel,
            @ApiParam(value = "仓库") @RequestParam(value = "stockName", defaultValue = "", required = false) String stockName,
            @ApiParam(value = "结束时间") @RequestParam(value = "dateEnd", defaultValue = "", required = false) String dateEnd,
            @ApiParam(value = "物料代码") @RequestParam(value = "materialNumber", defaultValue = "", required = false) String materialNumber
    ) {
//        return k3SafetyInTheWarehouseStatusService.safetyInTheWarehouseStatusSync(param);
        return reportService.getRemoteDataOfBefore(4, materielName, materialNumber, dateStart, dateEnd, stockName, pageSize, pageNo, null, materialModel);
    }

    @EvApiByToken(value = "/apis/exportExcel/safetyInTheWarehouseStatus", method = RequestMethod.GET, apiTitle = "成型生产指示分页列表(导出)")
    @ApiOperation("安全在库现况(导出)")
    public void safetyInTheWarehouseStatus(
            @ApiParam(value = "起始时间") @RequestParam(value = "dateStart", defaultValue = "", required = false) String dateStart,
            @ApiParam(value = "仓库") @RequestParam(value = "stockName", defaultValue = "", required = false) String stockName,
            @ApiParam(value = "物料名称") @RequestParam(value = "materielName", defaultValue = "", required = false) String materielName,
            @ApiParam(value = "规格型号") @RequestParam(value = "materialModel", defaultValue = "", required = false) String materialModel,
            @ApiParam(value = "结束时间") @RequestParam(value = "dateEnd", defaultValue = "", required = false) String dateEnd,
            @ApiParam(value = "物料代码") @RequestParam(value = "materialNumber", defaultValue = "", required = false) String materialNumber,
            HttpServletRequest request, HttpServletResponse response,
            ModelMap modelMap) {
        Map<String, Object> map = Maps.newHashMap();
        Integer pageNo = new Integer(1);
        Integer pageSize = new Integer(20);
        R remoteDataOfBefore = reportService.getRemoteDataOfBefore(4, materielName, materialNumber, dateStart, dateEnd, stockName, pageSize, pageNo, null, materialModel);
        if (!ObjectUtils.isEmpty(remoteDataOfBefore) && ObjectUtil.isNotEmpty(remoteDataOfBefore.get("total"))) {
            pageSize = new Integer(remoteDataOfBefore.get("total").toString());
            pageNo = 1;
            R remoteDataOfBefore2 = reportService.getRemoteDataOfBefore(4, materielName, materialNumber, dateStart, dateEnd, stockName, pageSize, pageNo, null, materialModel);
            log.debug("===============================remoteDataOfBefore2:{}", remoteDataOfBefore2);
            if (!ObjectUtils.isEmpty(remoteDataOfBefore2) && ObjectUtil.isNotEmpty(remoteDataOfBefore2.get("total"))) {
                JSONArray data = (JSONArray) remoteDataOfBefore2.get("data");
                for (Object item : data) {
                    JSONObject jsonObject = (JSONObject) item;
                    jsonObject.put("dateStart", dateStart);
                    jsonObject.put("dateEnd", dateEnd);
                }
                map.put("list", data);
                log.debug("===============================data:{}", data);
            }
        }
        ClassPathResource classPathResource = new ClassPathResource(
                "poi/SafetyInTheWarehouseStatus.xlsx");
        TemplateExportParams result = new TemplateExportParams(classPathResource.getPath());
        modelMap.put(TemplateExcelConstants.FILE_NAME, "安全在库现况");
        modelMap.put(TemplateExcelConstants.PARAMS, result);
        modelMap.put(TemplateExcelConstants.MAP_DATA, map);
        PoiBaseView.render(modelMap, request, response,
                TemplateExcelConstants.EASYPOI_TEMPLATE_EXCEL_VIEW);
    }


    @EvApiByToken(value = "/apis/asl/report/ExpectedStatusInTheLibrary/query", method = RequestMethod.POST, apiTitle = "5——预计在库现况(材料/产品)")
    @ApiOperation("5——预计在库现况(材料/产品)")
    public R expectedStatusInTheLibrary(@ApiParam(value = "当前第几页", required = true) @RequestParam(value = "pageno", defaultValue = "1") Integer pageNo,
                                        @ApiParam(value = "一页多少条", required = true) @RequestParam(value = "pagesize", defaultValue = "20") Integer pageSize,
                                        @ApiParam(value = "起始时间") @RequestParam(value = "dateStart", defaultValue = "", required = false) String dateStart,
                                        @ApiParam(value = "物料名称") @RequestParam(value = "materielName", defaultValue = "", required = false) String materielName,
                                        @ApiParam(value = "结束时间") @RequestParam(value = "dateEnd", defaultValue = "", required = false) String dateEnd,
                                        @ApiParam(value = "物料代码") @RequestParam(value = "materialNumber", defaultValue = "", required = false) String materialNumber,
                                        @ApiParam(value = "规格型号") @RequestParam(value = "materialModel", defaultValue = "", required = false) String materialModel,
                                        @ApiParam(value = "仓库") @RequestParam(value = "stockName", defaultValue = "", required = false) String stockName) {
//        return k3ExpectedStatusInTheLibraryService.expectedStatusInTheLibrarySync(param);
        Date date = new Date();
        DateTime startDate = DateUtil.offset(date, DateField.YEAR, -1);
        DateTime endDate = DateUtil.offset(date, DateField.YEAR, 1);
        SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
        dateStart = sd.format(startDate);
        dateEnd = sd.format(endDate);
        return reportService.getRemoteDataOfBefore(5, materielName, materialNumber, dateStart, dateEnd, stockName, pageSize, pageNo, null, materialModel);
    }

    @EvApiByToken(value = "/apis/exportExcel/expectedStatusInTheLibrary", method = RequestMethod.GET, apiTitle = "成型生产指示分页列表(导出)")
    @ApiOperation("5—预计在库现况(导出)")
    public void expectedStatusInTheLibrary(
            @ApiParam(value = "起始时间") @RequestParam(value = "dateStart", defaultValue = "", required = false) String dateStart,
            @ApiParam(value = "仓库") @RequestParam(value = "stockName", defaultValue = "", required = false) String stockName,
            @ApiParam(value = "物料名称") @RequestParam(value = "materielName", defaultValue = "", required = false) String materielName,
            @ApiParam(value = "规格型号") @RequestParam(value = "materialModel", defaultValue = "", required = false) String materialModel,
            @ApiParam(value = "结束时间") @RequestParam(value = "dateEnd", defaultValue = "", required = false) String dateEnd,
            @ApiParam(value = "物料代码") @RequestParam(value = "materialNumber", defaultValue = "", required = false) String materialNumber,
            HttpServletRequest request, HttpServletResponse response,
            ModelMap modelMap) {
        Date date = new Date();
        DateTime startDate = DateUtil.offset(date, DateField.YEAR, -1);
        DateTime endDate = DateUtil.offset(date, DateField.YEAR, 1);
        SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
        dateStart = sd.format(startDate);
        dateEnd = sd.format(endDate);
        Map<String, Object> map = Maps.newHashMap();
        Integer pageNo = new Integer(1);
        Integer pageSize = new Integer(20);
        R remoteDataOfBefore = reportService.getRemoteDataOfBefore(5, materielName, materialNumber, dateStart, dateEnd, stockName, pageSize, pageNo, null, materialModel);
        if (!ObjectUtils.isEmpty(remoteDataOfBefore) && ObjectUtil.isNotEmpty(remoteDataOfBefore.get("total"))) {
            pageSize = new Integer(remoteDataOfBefore.get("total").toString());
            pageNo = 1;
            R remoteDataOfBefore2 = reportService.getRemoteDataOfBefore(5, materielName, materialNumber, dateStart, dateEnd, stockName, pageSize, pageNo, null, materialModel);
            log.debug("===============================remoteDataOfBefore2:{}", remoteDataOfBefore2);
            if (!ObjectUtils.isEmpty(remoteDataOfBefore2) && ObjectUtil.isNotEmpty(remoteDataOfBefore2.get("total"))) {
                JSONArray data = (JSONArray) remoteDataOfBefore2.get("data");
                map.put("list", data);
                log.debug("===============================data:{}", data);
            }
        }
        ClassPathResource classPathResource = new ClassPathResource(
                "poi/expectedStatusInTheLibrary.xlsx");
        TemplateExportParams result = new TemplateExportParams(classPathResource.getPath());
        modelMap.put(TemplateExcelConstants.FILE_NAME, "预计在库现况");
        modelMap.put(TemplateExcelConstants.PARAMS, result);
        modelMap.put(TemplateExcelConstants.MAP_DATA, map);
        PoiBaseView.render(modelMap, request, response,
                TemplateExcelConstants.EASYPOI_TEMPLATE_EXCEL_VIEW);
    }

    @EvApiByToken(value = "/apis/asl/report/finalGoodsInStockSiteAsIs/query", method = RequestMethod.POST, apiTitle = "6——成品在库位置现况")
    @ApiOperation("6——成品在库位置现况-未被使用，实际使用的是2")
    public R queryMaterialOutboundDetail(
            @ApiParam(value = "起始时间") @RequestParam(value = "dateStart", defaultValue = "", required = false) String dateStart,
            @ApiParam(value = "结束时间") @RequestParam(value = "dateEnd", defaultValue = "", required = false) String dateEnd,
            @ApiParam(value = "物料代码") @RequestParam(value = "materialNumber", defaultValue = "", required = false) String materialNumber,
            @ApiParam(value = "仓库") @RequestParam(value = "stockName", defaultValue = "", required = false) String stockName,
            @ApiParam(value = "当前第几页", required = true) @RequestParam(value = "pageno", defaultValue = "1") Integer pageNo,
            @ApiParam(value = "一页多少条", required = true) @RequestParam(value = "pagesize", defaultValue = "20") Integer pageSize
    ) {
//        return k3FinalGoodsInStockSiteAsIsService.finalGoodsInStockSiteAsIsSync(param);

        return reportService.getRemoteDataOfBefore(6, null, materialNumber, dateStart, dateEnd, stockName, pageSize, pageNo, null, null);
    }

    @EvApiByToken(value = "/apis/exportExcel/finalGoodsInStockSiteAsIs", method = RequestMethod.GET, apiTitle = "成型生产指示分页列表(导出)")
    @ApiOperation("6—成品在库位置现况(导出)")
    public void finalGoodsInStockSiteAsIs(
            @ApiParam(value = "物料代码") @RequestParam(value = "materialNumber", defaultValue = "", required = false) String materialNumber,
            @ApiParam(value = "仓库") @RequestParam(value = "stockName", defaultValue = "", required = false) String stockName,
            @ApiParam(value = "物料名称") @RequestParam(value = "materielName", defaultValue = "", required = false) String materielName,
            @ApiParam(value = "物料名称") @RequestParam(value = "materialModel", defaultValue = "", required = false) String materialModel,
            @ApiParam(value = "起始时间") @RequestParam(value = "dateStart", defaultValue = "", required = false) String dateStart,
            @ApiParam(value = "结束时间") @RequestParam(value = "dateEnd", defaultValue = "", required = false) String dateEnd,
            HttpServletRequest request, HttpServletResponse response,
            ModelMap modelMap) {
        Map<String, Object> map = Maps.newHashMap();
//        Integer pageNo = new Integer(1);
//        Integer pageSize = new Integer(20);
//        R remoteDataOfBefore = reportService.getRemoteDataOfBefore(2, null, materialNumber, dateStart, dateEnd, stockName, pageSize, pageNo, null);
        String filter = "";
        if (ObjectUtil.isNotEmpty(materialNumber)) filter = filter + " and 物料代码='" + materialNumber + "'";
        if (ObjectUtil.isNotEmpty(stockName)) filter = filter + " and 仓库名称='" + stockName + "'";
        if (ObjectUtil.isNotEmpty(stockName))
            filter = filter + " and 物料名称 like '" + ("%" + materielName + "%") + "'";
        if (ObjectUtil.isNotEmpty(stockName))
            filter = filter + " and 规格型号 like '" + ("%" + materialModel + "%") + "'";
        Triple<Boolean, String, List<KisReceiveStockVo>> stockList = kisBasicsService.realTimeStockBalanceEnquiry222(filter);
        List<KisReceiveStockVo> right = stockList.getRight();
        List<ReportTwoVo> collect = new ArrayList<>();
        List<ReportTwoVo> reportTwoVos = new ArrayList<>();
        Map<String, Map<String, Object>> stockInListMap = new HashMap<>();
        BigDecimal totalStockQty = new BigDecimal(AslConstant.ZERO);
        if (ObjectUtil.isNotEmpty(right)) {
            List<String> batchNos = right.stream().map(KisReceiveStockVo::getFBatchNo).flatMap(batch -> Arrays.stream(batch.split(","))).distinct().collect(Collectors.toList());
            HashMap<String, Object> stockDOSMap = new HashMap<>();
            stockDOSMap.put("batchs", batchNos);
            List<Map<String, Object>> stockInList = aslBarCodeDao.getStockInList(stockDOSMap);
            stockInListMap = stockInList
                    .stream().collect(Collectors.toMap(item -> item.get("batchNo").toString(), item -> item, (v1, v2) -> v1));
        }
        if (right.size() > 0) {
            for (KisReceiveStockVo item : right) {
                try {
                    ReportTwoVo vo = new ReportTwoVo();
                    Map<String, Object> stockDO = new HashMap<>();
                    ArrayList<String> batchs = ObjectUtil.isNotEmpty(item.getFBatchNo()) ? new ArrayList(Arrays.asList(item.getFBatchNo().split(","))) : new ArrayList<String>();
                    if (ObjectUtil.isNotEmpty(batchs) && stockInListMap.containsKey(batchs.get(0))) {
                        stockDO = stockInListMap.get(batchs.get(0));
                    }
                    vo.setOperatorName(ObjectUtil.isNotEmpty(stockDO.get("operatorName")) ? stockDO.get("operatorName").toString() : "");
                    vo.setInTime(ObjectUtil.isNotEmpty(stockDO.get("createTime")) ? stockDO.get("createTime").toString() : "");
                    vo.setBatchNo(item.getFBatchNo());
                    vo.setMaterialNumber(item.getMaterialCode());
                    vo.setMaterialName(item.getFItemName());
                    vo.setMaterialModel(item.getFModel());
                    vo.setUnitName(item.getUnitName());
                    vo.setStock(item.getFStockId_FName());
                    vo.setMaterieCode(item.getMaterialCode());
                    vo.setStockQty(new BigDecimal(Double.valueOf(item.getFQty())));
                    vo.setFreightSpace(item.getFStockPlaceID_FName());
                    vo.setFrecords(Integer.valueOf(item.getFRECORDS()));
                    totalStockQty = totalStockQty.add(vo.getStockQty());
                    reportTwoVos.add(vo);
                } catch (Exception e) {
                    log.info("----2  数据解析出现异常：");
                }
            }
        }
        if (!CollectionUtils.isEmpty(reportTwoVos)) {
            collect = reportTwoVos.stream().sorted(Comparator.comparing(e -> e.getFrecords())).collect(Collectors.toList());
        }
        map.put("list", JSONArray.parseArray(JSON.toJSONString(collect)));
        map.put("totalStockQty", totalStockQty);
        ClassPathResource classPathResource = new ClassPathResource(
                "poi/MaterialStoragePresentState.xlsx");
        TemplateExportParams result = new TemplateExportParams(classPathResource.getPath());
        modelMap.put(TemplateExcelConstants.FILE_NAME, "成品在库位置现况");
        modelMap.put(TemplateExcelConstants.PARAMS, result);
        modelMap.put(TemplateExcelConstants.MAP_DATA, map);
        PoiBaseView.render(modelMap, request, response,
                TemplateExcelConstants.EASYPOI_TEMPLATE_EXCEL_VIEW);
    }

    @EvApiByToken(value = "/apis/asl/report/queryCtWpDatabase/query", method = RequestMethod.POST, apiTitle = "7--理论与实际在库对比现况")
    @ApiOperation("7--理论与实际在库对比现况")
    public R queryCtWpDatabase(
            @ApiParam(value = "物料代码") @RequestParam(value = "materialNumber", defaultValue = "", required = false) String materialNumber,
            @ApiParam(value = "仓库") @RequestParam(value = "stockName", defaultValue = "", required = false) String stockName,
            @ApiParam(value = "物料名称") @RequestParam(value = "materielName", defaultValue = "", required = false) String materielName,
            @ApiParam(value = "规格型号") @RequestParam(value = "materialModel", defaultValue = "", required = false) String materialModel,
            @ApiParam(value = "起始时间") @RequestParam(value = "dateStart", defaultValue = "", required = false) String dateStart,
            @ApiParam(value = "结束时间") @RequestParam(value = "dateEnd", defaultValue = "", required = false) String dateEnd,
            @ApiParam(value = "当前第几页", required = true) @RequestParam(value = "pageno", defaultValue = "1") Integer pageNo,
            @ApiParam(value = "一页多少条", required = true) @RequestParam(value = "pagesize", defaultValue = "20") Integer pageSize
    ) {
//        return k3CtWpDatabaseService.ctWpDatabaseSync(param);

        return reportService.getRemoteDataOfBefore(7, materielName, materialNumber, dateStart, dateEnd, stockName, pageSize, pageNo, null, materialModel);
    }

    @EvApiByToken(value = "/apis/exportExcel/queryCtWpDatabase", method = RequestMethod.GET, apiTitle = "成型生产指示分页列表(导出)")
    @ApiOperation("7-物料入库明细(导出)")
    public void queryCtWpDatabase(
            @ApiParam(value = "物料代码") @RequestParam(value = "materialNumber", defaultValue = "", required = false) String materialNumber,
            @ApiParam(value = "仓库") @RequestParam(value = "stockName", defaultValue = "", required = false) String stockName,
            @ApiParam(value = "物料名称") @RequestParam(value = "materielName", defaultValue = "", required = false) String materielName,
            @ApiParam(value = "规格型号") @RequestParam(value = "materialModel", defaultValue = "", required = false) String materialModel,
            @ApiParam(value = "起始时间") @RequestParam(value = "dateStart", defaultValue = "", required = false) String dateStart,
            @ApiParam(value = "结束时间") @RequestParam(value = "dateEnd", defaultValue = "", required = false) String dateEnd,
            HttpServletRequest request, HttpServletResponse response,
            ModelMap modelMap) {
        Map<String, Object> map = Maps.newHashMap();
        Integer pageNo = new Integer(1);
        Integer pageSize = new Integer(20);
        R remoteDataOfBefore = reportService.getRemoteDataOfBefore(7, null, materialNumber, dateStart, dateEnd, stockName, pageSize, pageNo, null, materialModel);
        if (!ObjectUtils.isEmpty(remoteDataOfBefore) && ObjectUtil.isNotEmpty(remoteDataOfBefore.get("total"))) {
            pageSize = new Integer(remoteDataOfBefore.get("total").toString());
            pageNo = 1;
            R remoteDataOfBefore2 = reportService.getRemoteDataOfBefore(7, materielName, materialNumber, dateStart, dateEnd, stockName, pageSize, pageNo, null, materialModel);
            log.debug("===============================remoteDataOfBefore2:{}", remoteDataOfBefore2);
            if (!ObjectUtils.isEmpty(remoteDataOfBefore2) && ObjectUtil.isNotEmpty(remoteDataOfBefore2.get("total"))) {
                JSONArray data = (JSONArray) remoteDataOfBefore2.get("data");
                map.put("list", data);
                log.debug("===============================data:{}", data);
            }
        }
        ClassPathResource classPathResource = new ClassPathResource(
                "poi/queryCtWpDatabase.xlsx");
        TemplateExportParams result = new TemplateExportParams(classPathResource.getPath());
        modelMap.put(TemplateExcelConstants.FILE_NAME, "物料入库明细");
        modelMap.put(TemplateExcelConstants.PARAMS, result);
        modelMap.put(TemplateExcelConstants.MAP_DATA, map);
        PoiBaseView.render(modelMap, request, response,
                TemplateExcelConstants.EASYPOI_TEMPLATE_EXCEL_VIEW);
    }

    @EvApiByToken(value = "/apis/asl/report/SalesStoreHouseByClient/query", method = RequestMethod.POST, apiTitle = "8--查看销售出库(根据客户)报表")
    @ApiOperation("8--查看销售出库(根据客户)报表")
    public R queryByClient(
            @ApiParam(value = "当前第几页", required = true) @RequestParam(value = "pageno", defaultValue = "1") int pageno,
            @ApiParam(value = "一页多少条", required = true) @RequestParam(value = "pagesize", defaultValue = "20") int pagesize,
            @ApiParam(value = "年份", required = true) @RequestParam(value = "yearDate", defaultValue = "") String yearDate
    ) {
//        return k3SalesStoreHouseService.salesStoreHouseByClientSync(param);
        return reportService.getRemoteDataOfBefore(8, null, null, null, null, null, pagesize, pageno, yearDate, null);
    }

    @EvApiByToken(value = "/apis/asl/report/SalesStoreHouseByProduct/query", method = RequestMethod.POST, apiTitle = "9--查看销售出库(根据物料)报表")
    @ApiOperation("9--查看销售出库(根据物料)报表")
    public R queryByProduct(
            @ApiParam(value = "当前第几页", required = true) @RequestParam(value = "pageno", defaultValue = "1") int pageno,
            @ApiParam(value = "一页多少条", required = true) @RequestParam(value = "pagesize", defaultValue = "10") int pagesize,
            @ApiParam(value = "年份", required = true) @RequestParam(value = "yearDate", defaultValue = "") String yearDate
    ) {
//        return k3SalesStoreHouseService.salesStoreHouseByProductSync(param);

        return reportService.getRemoteDataOfBefore(9, null, null, null, null, null, pagesize, pageno, yearDate, null);
    }


}
